<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改支点信息</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
    <script src="/js/jquery.validation/1.14.0/messages_zh.min.js"></script>


    <style>
        input.error {
            border: 1px solid #E6594E;
        }
    </style>
</head>
<body>
<script src="/js/webSocket.js"></script>
<div class="container">
    <form id="editBranchForm">
        <input type="hidden" id="buuid" name="buuid" value="${branch.buuid}">
        <br />
        <div class="form-group">
            <label for="bname">支点名称：</label> <input type="text"
                                                    class="form-control" id="bname" name="bname" placeholder="输入支点名称" value="${branch.bname}">
        </div>
        <div class="form-group">
            <label for="btelephone">支点电话：</label> <input type="text"
                                                         class="form-control" id="btelephone" name="btelephone"
                                                         placeholder="输入支点电话" value="${branch.btelephone}">
        </div>
        <div class="form-group">
            <label for="bcity">所在城市：</label> <input type="text"
                                                    class="form-control" id="bcity" name="bcity" placeholder="输入支点所在城市" value="${branch.bcity}">
        </div>
        <div class="form-group">
            <label for="blocation">详细信息：</label> <input type="text"
                                                        class="form-control" id="blocation" name="blocation" placeholder="输入详细信息" value="${branch.blocation}">
        </div>
        <div class="form-group">
            <label for="uname">负责人：</label> <input type="text"
                                                   class="form-control" id="uname" name="uname" placeholder="输入负责人" value="${branch.uname}">
        </div>
        <div class="form-group">
            <label for="phone">负责人电话：</label> <input type="text"
                                                   class="form-control" id="phone" name="phone" placeholder="输入负责人电话" value="${branch.phone}">
        </div>
        <div class="form-group">
            <label for="blongitude">经度：</label> <input type="text" class="form-control"
                                                       id="blongitude" name="blongitude" placeholder="输入位置的经度" value="${branch.blongitude}">
        </div>
        <div class="form-group">
            <label for="bdimension">维度：</label> <input type="text" class="form-control"
                                                       id="bdimension" name="bdimension" placeholder="输入位置的维度" value="${branch.bdimension}">
        </div>
        <div class="form-group">
            <label for="bdesc">备注：</label> <input type="text" class="form-control"
                                                  id="bdesc" name="bdesc" placeholder="输入备注" value="${branch.bdesc}">
        </div>

        <div class="form-group">
            <label for="quarter1">第一季度：</label> <input type="text" class="form-control"
                                                     id="quarter1" name="quarter1" placeholder="输入第一季度财务统计" value="${branch.quarter1}">
        </div>
        <div class="form-group">
            <label for="quarter2">第二季度：</label> <input type="text" class="form-control"
                                                     id="quarter2" name="quarter2" placeholder="输入第二季度财务统计" value="${branch.quarter2}">
        </div>
        <div class="form-group">
            <label for="quarter3">第三季度：</label> <input type="text" class="form-control"
                                                     id="quarter3" name="quarter3" placeholder="输入第三季度财务统计"  value="${branch.quarter3}">
        </div>
        <div class="form-group">
            <label for="quarter4">第四季度：</label> <input type="text" class="form-control"
                                                     id="quarter4" name="quarter4" placeholder="输入第四季度财务统计"  value="${branch.quarter4}">
        </div>
        <div class="form-group">
            <button type="button" id="editBtn" class="btn btn-success">提交</button>
            <button type="button" id="cancelBtn" class="btn btn-default">取消</button>
        </div>
    </form>
</div>


</body>
</html>
<script type="text/javascript">

    var editBranch=function () {
        if(!check().form()){
            return;
        }
        $.ajax({
            type:"POST",
            url:"/branch/update",
            contextType:"application/json",
            data:$("#editBranchForm").serialize(),
            success:function () {
                $("#cancelBtn").click();
            }
        });
    }

    $("#cancelBtn").click(function () {
        var index=parent.layer.getFrameIndex(window.name);
        parent.getBranchList();
        parent.layer.close(index);
    });
    $("#editBtn").click(function () {
       editBranch();
     });
    function check() {
        return $("#editBranchForm").validate({
            rules:{
                bname:{
                    required:true
                },
                btelephone:{
                    required:true
                },
                bcity:{
                    required:true
                },
                blocation:{
                    required:true
                },
                uname:{
                    required:true
                },
                phone:{
                    required:true
                },
                blongitude:{
                    required:true
                },
                bdimension:{
                    required:true
                },
                bdesc:{
                    required:true
                },
                quarter1:{
                    required:true
                },
                quarter2:{
                    required:true
                },
                quarter3:{
                    required:true
                },
                quarter4:{
                    required:true
                }

            },
            messages:{
                bname:{
                    required:""
                },
                btelephone:{
                    required:""
                },
                bcity:{
                    required:""
                },
                blocation:{
                    required:""
                },
                uname:{
                    required:""
                },
                phone:{
                    required:""
                },
                blongitude:{
                    required:""
                },
                bdimension:{
                    required:""
                },
                bdesc:{
                    required:""
                },
                quarter1:{
                    required:""
                },
                quarter2:{
                    required:""
                },
                quarter3:{
                    required:""
                },
                quarter4:{
                    required:""
                }


            }
        });
    }
</script>